package net.phoenix.repository.nodetype;

import java.util.Collection;
import java.util.List;
import java.util.Vector;

import javax.jcr.nodetype.NodeType;
import javax.jcr.nodetype.NodeTypeIterator;

/**
 * Jigsaw server
 * 
 * @author <a href="shamphone@gmail.com">Li XiongFeng</a>
 * @date 2012-1-4
 * @version 1.0.0
 */
public class BasicNodeTypeIterator implements NodeTypeIterator {

	private List<NodeType> types;
	private int position = -1;

	public BasicNodeTypeIterator(Collection<NodeType> types) {
		this.types = new Vector<NodeType>(types);
	}

	@Override
	public void skip(long skipNum) {
		this.position += skipNum;

	}

	@Override
	public long getSize() {
		return this.types.size();
	}

	@Override
	public long getPosition() {
		return this.position;
	}

	@Override
	public boolean hasNext() {
		return this.position + 1 < this.types.size();
	}

	@Override
	public Object next() {
		return nextNodeType();
	}

	@Override
	public void remove() {

	}

	@Override
	public NodeType nextNodeType() {
		this.position++;
		return this.types.get(position);
	}

}
